(function () {
    if (document.querySelectorAll) {
        for (var i = 0, img = document.querySelectorAll("img"); i < img.length; i++) {
            img[i].onerror = function () { this.src = "" }; img[i].src = img[i].src;
        }
    }
    try {
        new MutationObserver(function (record) {
            for (var i = 0, nodes = record[0].addedNodes; i < nodes.length && nodes[i].tagName && nodes[i].tagName.toLowerCase() === "img"; i++) {
                nodes[i].onerror = function () { this.src = "" }
            }
        }).observe(document.body, { childList: true, subtree: true });
    } catch (err) {}
})()


function q (q) {
    if (document.querySelectorAll) {
        var ele = document.querySelectorAll(q);
        if (ele.length > 1) return ele;
        else if ((ele.length == 1)) return ele[0];
        else return undefined;
    } else {
        return document.querySelector(q) || undefined;
    } 
}

function easeAnime (s, runFN, lastFN, clean) {
    if (s === false) { window.easeAnimeSTOP = false; return; }
    if (clean) window.easeAnimeSTOP = window.easeAnimeSTOP ? false : true;
    var t = 0, easing = {
        easeIn: function (t) {
            return -(s[1]-s[0]) * Math.cos(t/s[2] * (Math.PI/2)) + (s[1]-s[0]) + s[0];
        },
        easeOut: function (t) {
            return (s[1]-s[0]) * Math.sin(t/s[2] * (Math.PI/2)) + s[0];
        },
        easeInOut: function (t) {
            return -(s[1]-s[0])/2 * (Math.cos(Math.PI*t/s[2]) - 1) + s[0];
        },
        easeStrong: function (t) {
            return -(s[1]-s[0]) * (Math.pow(t/s[2] - 1, 4) - 1) + s[0];
        }
    };
    var setFN = function () {
        var t = 0; var anime = setInterval(function () {
            if (t >= s[2] || (clean && window.easeAnimeSTOP)) {
                clearInterval(anime);
                window.easeAnimeSTOP = true;
                lastFN && lastFN();
            }
            else {
                if (clean) window.easeAnimeSTOP = false;
                t = t + 16 >= s[2] ? s[2] : t + 16;
                runFN.call({}, easing[s[3] || "easeInOut"](t));
            }
        }, 16);
    }
    if (!s[4]) setFN();
    else setTimeout(setFN, s[4]);
}

function fullCSS (config, set, get, setMethod, getMethod, getType) {
    var ele;
    if (config instanceof HTMLElement) {
        ele = config;
    } else if (typeof config === "object") {
        ele = config.element || config.ele,
        set = config.set,
        get = config.get,
        getType = config.getType,
        getMethod = config.getMethod,
        setMethod = config.setMethod;
    }
    if (typeof ele === "string") ele = document.querySelector(ele);
    if (!ele) return;

    function numGen (val) {
        var FEnum = String(val).match(/\-?(\d+\.|\.?)\d+(e|E)[\+\-]?\d+/),
            GEnum = String(val).match(/\-?(\d+\.|\.?)\d+/);
        if (FEnum) {
            var res = "", p1 = "", p2 = "", pm = 1; FEnum = FEnum[0];
            if (FEnum.indexOf("-") === 0) pm = 0, FEnum = FEnum.substr(1);
            FEnum = FEnum.replace(/^0+/, "").replace(/^\./, "0.");
            var dot = FEnum.indexOf("."),
                power = Number(FEnum.match(/\d+$/)[0]) || 0,
                ONnum = FEnum.replace(/(e|E).+$/, "").replace(/(\.\d+?)0+$/, "$1").replace(/\.0+$|\./g, "");
            if (dot != -1) {
                p1 = ONnum.substring(0, dot),
                p2 = ONnum.substring(dot, ONnum.length);
            }
            if (FEnum.indexOf("-") != -1) {
                if (dot == -1) {
                    ONnum = ONnum.replace(/^0+/, "");
                    if (power < ONnum.length) {
                        res = ONnum.substr(0, ONnum.length - power) + "." + ONnum.substr(-power);
                    } else {
                        for (var i = 0, le = power - ONnum.length; i < le; i++) ONnum = "0" + ONnum;
                        res = "0." + ONnum;
                    }
                } else {
                    if (!(/[^0]/.test(p1))) {
                        p1 = "0."; for (var i = 0; i < power; i++) p1 += "0";
                    } else if (power < p1.length) {
                        p1 = p1.substr(0, p1.length - power) + "." + p1.substr(-power);
                    } else {
                        for (var i = 0, le = power - p1.length; i < le; i++) p1 = "0" + p1;
                        p1 = "0." + p1;
                    }
                    res = p1 + p2;
                }
            } else {
                if (dot == -1) {
                    res = ONnum.replace(/^0+/, "");
                    for (var i = 0; i < power; i++) res += "0";
                } else {
                    if (power < p2.length) {
                        p2 = p2.substr(0, power) + "." + p2.substr(power);
                    } else {
                        for (var i = 0, le = power - p2.length; i < le; i++) p2 += "0";
                    }
                    res = p1 + p2;
                }
            }
            res = res.replace(/^0+(?!\.)/, "").replace(/(\.\d+?)0+$/, "$1").replace(/\.0+$|\.$/, "");
            if (!Number.isNaN(Number(res)) && !String(Number(res)).match(/e|E/) && Number.isFinite(Number(res))) {
                res = pm < 1 ? -Number(res) : Number(res);
            } else {
                res = pm < 1 ? "-" + res : res
            }
            return res;
        } else if (GEnum && !Number.isNaN(Number(GEnum[0])) && Number.isFinite(Number(GEnum[0]))) {
            return Number(GEnum[0]);
        } else {
            return typeof val != "number" && !Number.isNaN(Number(val)) && Number.isFinite(Number(val)) ? Number(val) : val;
        }
    }

    function u (val, unit, type) {
        var jo;
        if (type && Array.isArray(type)) jo = type[1], type = type[0];
        else if (!type) type = getType;
        if (type == "number") {
            var reNum = function (v) {
                if (typeof v === "string" && /\d/.test(v)) {
                    var reVal = function (val, reps) {
                        if (reps != void 0) {
                            if (Array.isArray(reps)) {
                                var tp = typeof val; val = String(val);
                                reps.forEach(function (r, i) {
                                    if (r !== "" && r !== void 0) {
                                        r = new RegExp(r);
                                        if (r.test(val)) val = val.replace(r, "");
                                    }
                                });
                                if (tp == "number") val = Number(val);
                            } else if (reps !== "") {
                                var tp = typeof val, r = new RegExp(reps);
                                if (r.test(String(val))) {
                                    val = String(val).replace(r, "");
                                    val = tp == "number" ? Number(val) : val;
                                }
                            }
                        }
                        return val;
                    };
                    var valSplit = function (vals, sp) {
                        var vARR = [];
                        reVal(vals, /url\(.*\)/g).split(sp).forEach(function (va) {
                            if (va.match(/\-?(\d+\.|\.?)\d+(e|E)[\+\-]?\d+/) || va.match(/\-?(\d+\.|\.?)\d+/)) {
                                vARR.push(Number(numGen(va)));
                            } else {
                                va = va.replace(/[^\d\.\-\+]/g, "");
                                if (va && (Number(va) || Number(va) === 0))
                                vARR.push(Number(va));
                            }
                        });
                        return vARR;
                    };
                    if (/.+,.+/.test(v)) return valSplit(v, ",");
                    else if (/[^,] .+/.test(v)) return valSplit(v, " ");
                    else return Number(numGen(reVal(v, /url\(.*\)/g)));
                }
                else return v;
            };
            if (Array.isArray(val)) {
                var valARR = [];
                val.forEach(function (v, i) { valARR[i] = reNum(v) });
                return valARR;
            } else {
                return reNum(val);
            }
        } else {
            if (Array.isArray(val)) {
                var valARR = [];
                val.forEach(function (v, i) {
                    var FEnum = String(v).match(/[\+\-]?(\d+\.|\.?)\d+(e|E)[\+\-]?\d+/);
                    if (FEnum) {
                        var ov = String(v).split(FEnum[0]);
                        val = ov[0] || "" + numGen(FEnum[0]) + ov[1] || "";
                    }
                    valARR[i] = unit ? v + unit : v;
                });
                return valARR.join(jo || ", ");
            } else {
                var FEnum = String(val).match(/[\+\-]?(\d+\.|\.?)\d+(e|E)[\+\-]?\d+/);
                if (FEnum) {
                    var ov = String(val).split(FEnum[0]);
                    val = ov[0] || "" + numGen(FEnum[0]) + ov[1] || "";
                }
                val = type == "string" ? String(val) : val;
                return unit ? val + unit : val;
            }
        }
    }

    function getStyle (attr, valAttr, gMethod, vType) {
        var val; gMethod = gMethod || getMethod;
        if (gMethod == "inline") {
            val = ele.style[attr] != void 0 ? ele.style[attr] : "";
        } else if (gMethod == "computed") {
            val = ele.currentStyle ? ele.currentStyle[attr] : window.getComputedStyle(ele, null)[attr];
        } else if (ele.style[attr]) {
            val = ele.style[attr];
        } else {
            val = ele.currentStyle ? ele.currentStyle[attr] : window.getComputedStyle(ele, null)[attr];
        }
        if (valAttr && valAttr !== "value") {
            var valObj = {}, valObjAll = {}, oriValAttr = valAttr;
            if (typeof valAttr === "string") valAttr = [valAttr];
            if (/.+\(.*\)/.test(val)) {
                val.split(") ").forEach(function (v, i, t) {
                    if (i === t.length - 1) v = v.replace(/\)$/, "");
                    var vARR = v.split("(");
                    valObjAll[vARR[0]] = u(vARR[1], null, vType);
                });
                if ((attr === "transform" || attr === "webkitTransform" || attr === "-webkit-transform") &&
                    valObjAll["matrix"] && oriValAttr !== "all" && Object.keys(valAttr).length < 2) {
                    var mv = getType == "number" ? valObjAll["matrix"] : u(valObjAll["matrix"], null, "number");
                    var deg = function (val, type) {
                        var d = function (v, t, m) {
                            if (t == "tan") m = Math.atan(v);
                            else if (t == "sin") m = Math.asin(v);
                            else m = Math.acos(v);
                            return m * 180 / Math.PI;
                        };
                        if (type == "skew") {
                            return d(val, "tan");
                        } else if (type == "rotate") {
                            var r1 = Math.round(Math.acos(val[0]) * 180 / Math.PI),
                                r2 = Math.round(Math.asin(val[1]) * 180 / Math.PI),
                                r3 = -Math.round(Math.asin(val[2]) * 180 / Math.PI),
                                r4 = Math.round(Math.acos(val[3]) * 180 / Math.PI);
                            if (r1 == r2 && r1 == r3 && r1 == r4) return r1;
                        } else {
                            return d(val, type);
                        }
                    };
                    var matrixRotate = deg([mv[0],mv[1],mv[2],mv[3]], "rotate");
                    valObjAll = {
                        rotate : matrixRotate != void 0 ? u(matrixRotate, "deg") : "",
                        scaleX : mv[0],
                        scaleY : mv[3],
                        scale : u([mv[0], mv[3]]),
                        skewX : u(deg(mv[2], "skew"), "deg"),
                        skewY : u(deg(mv[1], "skew"), "deg"),
                        skew : u([deg(mv[2], "skew"), deg(mv[1], "skew")], "deg"),
                        translateX : u(mv[4], "px"),
                        translateY : u(mv[5], "px"),
                        translate : u([mv[4], mv[5]], "px"),
                        matrix : u(mv)
                    };
                }
            }
            if (oriValAttr === "all") {
                return valObjAll;
            } else {
                Object.keys(valAttr).forEach(function (v) {
                    v = valAttr[v];
                    valObj[v] = valObjAll[v] != void 0 ? valObjAll[v] : "";
                });
                valObj.value = val;
                return valObj;
            }
        } else {
            return u(val, null, vType);
        }
    }

    function getFN () {
        var valueObj = {};
        if (get == "all") {
            return ele.style;
        } else if (get == "cssText") {
            valueObj = { cssText : ele.style.cssText };
            for (var i = 0; i < ele.style.length; i++) {
                valueObj[ele.style[i]] = ele.style[ele.style[i]];
            }
            return valueObj;
        } else if (Array.isArray(get)) {
            get.forEach(function (v) {
                if (typeof v == "string") {
                    valueObj[v] = getStyle(v);
                } else {
                    Object.keys(v).forEach(function (va) {
                        valueObj[va] = getStyle(va, v[va]);
                    });
                }
            });
            return valueObj;
        } else if (typeof get == "object") {
            Object.keys(get).forEach(function (v) {
                valueObj[v] = getStyle(v, get[v]);
            });
            return valueObj;
        } else if (typeof get == "string") {
            return getStyle(get);
        }
    }

    function setFN () {
        if (typeof set === "string") {
            ele.style.cssText += set;
        } else if (setMethod == "add") {
            Object.keys(set).forEach(function (a) {
                if (typeof set[a] === "string") {
                    ele.style[a] = set[a];
                } else {
                    var oriVal = getStyle(a, null, "auto", "string");
                    if (/\d/.test(oriVal)) {
                        if (typeof set[a] === "number") {
                            var nu = Number(oriVal.replace(/[^\d\.\-\+]/g, "")) || "",
                                un = oriVal.match(/[^\d\.\-\+]+$/),
                                FEnum = oriVal.match(/\-?(\d+\.|\.?)\d+(e|E)[\+\-]?\d+/);
                            if (FEnum && !Number.isNaN(Number(FEnum[0]))) nu = Number(FEnum[0]);
                            ele.style[a] = numGen(set[a] + nu) + (un ? un[0] : "");
                        } else if (typeof set[a] === "object") {
                            var reSet = function (oriGup, setGup) {
                                var reGup = function (v) {
                                    var valSplit = function (vals, sp) {
                                        var vARR = [sp];
                                        vals.replace(/url\(.*\)/g, "").split(sp).forEach(function (v) {
                                            v = v.replace(/^ +/, "").replace(/ +$/, "");
                                            var nu = v.replace(/[^\d\.\-\+]/g, ""),
                                                un = v.match(/[^\d\.\-\+]+$/),
                                                FEnum = v.match(/\-?(\d+\.|\.?)\d+(e|E)[\+\-]?\d+/);
                                            if (FEnum && !Number.isNaN(Number(FEnum[0]))) nu = FEnum[0];
                                            if (nu && (Number(nu) || Number(nu) === 0))
                                            vARR.push([Number(nu), un ? un[0] : ""]);
                                        });
                                        return vARR;
                                    };
                                    if (/.+,.+/.test(v)) v = valSplit(v, ", ");
                                    else if (/[^,] .+/.test(v)) v = valSplit(v, " ");
                                    return v;
                                };
                                var setVal = "", oriGup = reGup(oriGup);
                                var sp = oriGup[0] || " ", un = "", le = setGup.length;
                                if (Array.isArray(setGup[le - 1])) {
                                    le = le - 1;
                                    if (setGup[le][0] || setGup[le][0] === "") {
                                        sp = setGup[le][0];
                                    }
                                    if (setGup[le][1]) {
                                        un = setGup[le][1];
                                    }
                                }
                                for (var i = 0; i < le; i++) {
                                    if (typeof setGup[i] === "number") {
                                        var oG = oriGup[i+1] ? oriGup[i+1] : ["", ""];
                                        setVal += numGen(setGup[i] + oG[0]) + (un ? un : oG[1]) + sp;
                                    } else {
                                        setVal += setGup[i] + un + sp;
                                    }
                                }
                                return sp === "" ? setVal : setVal.replace(RegExp(sp + "+$"), "").replace(/,* *$/, "");
                            };
                            if (Array.isArray(set[a])) {
                                ele.style[a] = reSet(oriVal, set[a]);
                            } else {
                                var setVal = "", valARR = getStyle(a, "all", "auto", "string");
                                Object.keys(set[a]).forEach(function (v) {
                                    if (valARR[v]) {
                                        if (typeof set[a][v] === "string") {
                                            valARR[v] = set[a][v];
                                        } else if (/\d/.test(valARR[v])) {
                                            if (typeof set[a][v] === "number") {
                                                var nu = Number(valARR[v].replace(/[^\d\.\-\+]/g, "")) || "",
                                                    un = valARR[v].match(/[^\d\.\-\+]+$/),
                                                    FEnum = valARR[v].match(/\-?(\d+\.|\.?)\d+(e|E)[\+\-]?\d+/);
                                                if (FEnum && !Number.isNaN(Number(FEnum[0]))) nu = Number(FEnum[0]);
                                                valARR[v] = numGen(set[a][v] + nu) + (un ? un[0] : "");
                                            } else if (Array.isArray(set[a][v])) {
                                                valARR[v] = reSet(valARR[v], set[a][v]);
                                            }
                                        }
                                    }
                                });
                                Object.keys(valARR).forEach(function (v) {
                                    if (v !== "value") setVal += v + "(" + valARR[v] + ") ";
                                });
                                ele.style[a] = setVal.replace(/,* *$/, "");
                            }
                        }
                    }
                }
            });
        } else {
            var reSet = function (val) {
                if (Array.isArray(val)) {
                    var setVal = "", sp = " ", un = "", le = val.length;
                    if (Array.isArray(val[le - 1])) {
                        le = le - 1;
                        if (val[le][0] || val[le][0] === "") {
                            sp = val[le][0];
                        }
                        if (val[le][1]) {
                            un = val[le][1];
                        }
                    }
                    for (var i = 0; i < le; i++) {
                        setVal += val[i] + un + sp;
                    }
                    return sp === "" ? setVal : setVal.replace(RegExp(sp + "+$"), "");
                } else {
                    return val;
                }
            };
            Object.keys(set).forEach(function (a) {
                if (typeof set[a] === "object") {
                    if (Array.isArray(set[a])) {
                        ele.style[a] = reSet(set[a]);
                    } else {
                        var setVal = "", valARR = getStyle(a, "all", "auto", "string");
                        Object.keys(set[a]).forEach(function (v) {
                            valARR[v] = reSet(set[a][v]);
                        });
                        Object.keys(valARR).forEach(function (v) {
                            if (v !== "value") setVal += v + "(" + valARR[v] + ") ";
                        });
                        ele.style[a] = setVal.replace(/,* *$/, "");
                    }
                } else {
                    ele.style[a] = set[a];
                }
            });
        }
    }

    if (set && get) {
        var fn1;
        Object.keys(config).forEach(function (v) {
            if (fn1) return;
            else if (v === "set" || v === "get") fn1 = v;
        });
        if (fn1 === "set") {
            setFN(); return getFN();
        } else {
            var getRes = getFN(); setFN(); return getRes;
        }
    } else if (set) {
        setFN();
    } else if (get) {
        return getFN();
    }
}